home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Add-Ons
/
HyperCard
/
CharCount XFCN 1.0.2
/
CharCount.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-07
|
1KB
|
69 lines
/* ----------------------------------------------------------------------
CharCount XFCN
version 1.0.2
Written by: Paul Celestin
Copyright © 1993-1995 Celestin Company, Inc.
This XFCN returns the number of times a specified character
appears in the source text.
Requires two parameters: search char, source text.
931204 - 1.0.0 - initial release
951215 - 1.0.1 - updated for CW7
960704 - 1.0.2 - updated for CW9
---------------------------------------------------------------------- */
#include <A4Stuff.h>
#include <HyperXCmd.h>
void DoIt(XCmdPtr paramPtr);
pascal void main(XCmdPtr paramPtr)
{
long oldA4 = SetCurrentA4();
DoIt( paramPtr );
SetA4(oldA4);
}
void DoIt(XCmdPtr paramPtr)
{
Str255 copyright = "\pCopyright © 1993-1996 Celestin Company, Inc.";
char *p,*c;
long count = 0;
Str255 myString;
if (paramPtr->paramCount != 2)
{
paramPtr->returnValue =
PasToZero(paramPtr,"\pRequires two parameters: search char, source text.");
}
else
{
MoveHHi(paramPtr->params[0]);
MoveHHi(paramPtr->params[1]);
HLock(paramPtr->params[0]);
HLock(paramPtr->params[1]);
p = *(paramPtr->params[0]);
c = *(paramPtr->params[1]);
while (*c)
{
if (*c++ == *p)
++count;
}
NumToStr(paramPtr,count,myString);
paramPtr->returnValue = PasToZero(paramPtr,myString);
HUnlock(paramPtr->params[0]);
HUnlock(paramPtr->params[1]);
}
}